@namespace SwashbucklerDiary.Rcl.Components
@typeparam TValue
@inherits DialogComponentBase

<CustomMDialog MyValue="Visible"
               MyValueChanged="InternalVisibleChanged"
               ContentClass="rounded-lg"
               MaxWidth="420"
               Scrollable="true">
    <MCard>
        <MCardTitle Class="font-weight-bold flex-nowrap">
            <wc-auto-scroll-text>@Title</wc-auto-scroll-text>
            <MSpacer></MSpacer>
            @if (ShowText is not null)
            {
                <MButton IconName="@((bool)ShowText ? "mdi:mdi-alphabetical" : "mdi:mdi-alphabetical-off")"
                         OnClick="UpdateShowText">
                </MButton>
            }

            <MButton Icon="true"
                     OnClick="HandleOnCancel">
                <MIcon>close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText Class="scroll-show pb-0 mb-5" Style="max-height:300px;">
            <MChipGroup Value="internalValue"
                        ValueChanged="InternalValueChanged"
                        Class="@(InternalShowText ? "" : "m-chip-group--icon")"
                        Column="true"
                        Mandatory="Mandatory">
                @foreach (var item in Items)
                {
                    <MChip @key="item.Key"
                           Value="@item.Key"
                           Filter="InternalShowText"
                           Outlined="!InternalShowText"
                           OnClick="HandleOnCancel">
                        <MIcon Left="InternalShowText">
                            @InternalItemIcon(item)
                        </MIcon>
                        @InternalItemText(item)
                    </MChip>
                }
            </MChipGroup>
        </MCardText>
    </MCard>
</CustomMDialog>
